package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.ExtIotViceProduct;
import com.econ.powercloud.ems.dal.entity.ext.SceneProduct;
import com.econ.powercloud.ems.dal.mapper.ExtIotViceProductMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ Description:
 * @ Author：hgp
 * @ Create:2022-05-23-17:11
 */
@Repository
public class ExtIotViceProductDAO extends ServiceImpl<ExtIotViceProductMapper, ExtIotViceProduct> {

    public ExtIotViceProduct getProductByProductKey(String productKey, String applicationCode) {
        LambdaQueryWrapper<ExtIotViceProduct> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(ExtIotViceProduct::getProductKey, productKey);
        wrapper.eq(StringUtils.isNotBlank(applicationCode), ExtIotViceProduct::getApplicationCode, applicationCode);
        return this.baseMapper.selectOne(wrapper);
    }

    public List<SceneProduct> getListByAppAndProducts(List<String> productKeys, String applicationCode) {
        return this.baseMapper.selectViceListByAppAndProductKeys(applicationCode,productKeys);
    }

}
